<?php
namespace Home\Controller;
use Think\Controller;

/**
 * Movie Related Display Controller
 *
 * @package Home\Controller
 * @author lythesia
**/
class MovieController extends Controller {
  /**
   * Display movie index page(single movie)
   *
   * @param  string movie_id(`$_GET[]`)
   * @return 
   * @author lythesia
   **/
  public function index($id) {
    $opt = array(
      'rel' => ['genres', 'director', 'persons', 'sim_movies'],
    );
    $field = 'id,title,aka,rating,mpaa,country,releasedate,runtime,producedby,budget,summary,poster,imdb_field,dbpedia_field';

    $data = A('Common/Movie')->getMovieRelById($id, $opt, $field);
    if(!$data) goto error;

    $data['imdb_field'] = explode(',', $data['imdb_field']);
    $data['dbpedia_field'] = explode(',', $data['dbpedia_field']);

    $this->assign('data', $data);
    $this->display('Movie/single-movie');
    return;

    error:
    $this->display('Common/404');
  }
}
